package com.fhzn.boss.web.request;

import com.fhzn.commons.toolkit.entity.PageRequest;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import lombok.AccessLevel;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Objects;

/**
 * @author fhzn
 */
@Data
@Accessors(chain = true)
@RequiredArgsConstructor(access = AccessLevel.PUBLIC, staticName = "typeOf")
public class DictQuery {

    private final String type;

    private List<String> codes;

    private String name;

    private String appCode;

    private Integer parentId;

    private Boolean ifHidden;

    private PageRequest page;

    public PageRequest getPage() {
        return Objects.isNull(page) ? new PageRequest() : page;
    }

    public List<String> getCodes() {
        return MoreObjects.firstNonNull(codes, ImmutableList.of());
    }
}
